﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script src="vendor/jquery/jquery.min.min.js"></script>
    <script>

        String.prototype.endWith = function (endStr) {
            var d = this.length - endStr.length;
            return (d >= 0 && this.lastIndexOf(endStr) == d)
        }
        var params = [];

        //获取url参数
        getUrlVars = function () {
            var vars = {};
            var hash;
            var hashs = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
            for (var i = 0; i < hashs.length; i++) {
                hash = hashs[i].split('=');
                vars[hash[0]] = hash[1];
            }
            return vars;
        }

        window.onload = function () {
        if (confirm("确认执行 行业信息变更 操作？")){
                //获取URL参数
                params = getUrlVars();


                // var paramString = JSON.stringify(params);
                $.ajax({
                    type: "POST",
                    async: false,
                    url: params["toUrl"],
                    data: params,
                    dataType: "json",
                    success: function (result) {
                        debugger;
                        //只有一个表单直接跳转打开
                        if (result.code ==0  && result.data  ) {
                            // InstanceSheets.html?InstanceId=30fb6c8c-c0f3-4095-b6e1-5578640add5d

                            var data = JSON.parse(result.data);

                            if (data.workItemUrl && data.workItemUrl  !="") {
                                window.location.href = data.workItemUrl;
                            }else if (data.instanceID) {
                                let toherf = "/Portal/InstanceSheetsTest.html?InstanceId="+data.instanceID;
                                console.log(toherf);
                                window.location.href =toherf;
                            }else{
                                window.parent.location.reload();
                            }

                        }else{
                            alert(result.msg);
                            window.parent.location.reload();
                        }
                    }
                });
        }else {


            // window.close();

            window.parent.location.reload();


        }


        }

    </script>
</head>
<body>
<div class="container">
    <div class="panel">
        <div class="panel-heading" style="display:none;">
            <span>请选择表单:</span>
        </div>
        <div class="panel-body">

        </div>
    </div>
</div>
</body>
</html>
